package com.junit5.demo;

import com.util.Calculator;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;

import java.util.ArrayList;

import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class Junit5Demo_1_1_AssertAll {

    @Test
    public void addTest() throws InterruptedException {
        ArrayList<Executable> arrayList=new ArrayList<>();
        int result = Calculator.add(4, 2);
        System.out.println("加法计算结果:" + result);
        arrayList.add(() -> assertEquals(6, result));

        int result2 = Calculator.add(1, -1);
        System.out.println("加法计算结果:" + result2);
        arrayList.add(() -> assertEquals(1, result2));


        int result3 = Calculator.add(0, 2);
        System.out.println("加法计算结果:" + result3);
        arrayList.add(() -> assertEquals(2, result3));


       /* assertAll("计算校验结果",
                () -> assertEquals(6, result),
                () -> assertEquals(0, result2),
                () -> assertEquals(2, result3)
        );*/

     /*   for (Executable executable : arrayList) {
            assertAll("计算校验结果",executable);
        }*/

        assertAll("计算校验结果",arrayList.stream());


    }

}
